package com.cml.common.constant;

import com.cml.common.serializable.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 姓名：陈茂林
 * 时间：2023/10/7 13:42
 * 描述：
 */
public class MessageType {
    /**
     * 连接信息
     */
    public  static  final  int CONN_MESSAGE=1;

    public  static  final  int VOTE=2;

    public static final int DEFAULT_MESSAGE=3;

    public static final int SOLT_METADATA_MESSAGE=4;

    public static final int CUR_SERVER_NODE_SOLT_METADATA_MESSAGE=5;

    public static final int CLIENT_REQUEST_SOLT_METADATA_MESSAGE=6;

    public static final int CLIENT_RESPONSE_SOLT_METADATA_MESSAGE=7;

    public static final int CLIENT_REQUEST_ALL_SERVER_LIST_MESSAGE=8;

    public static final int CLIENT_RESPONSE_ALL_SERVER_LIST_MESSAGE=9;

    public static final int CLIENT_REQUEST_SERVICE_REGISTER_MESSAGE=10;

    public static final int CLIENT_REPONSE_SERVICE_REGISTER_MESSAGE=11;

    public static final int CLIENT_REQUEST_SERVICE_HEARBEAT_MESSAGE=12;

    public static final int CLIENT_REPONSE_SERVICE_HEARBEAT_MESSAGE=13;

    public static final int CLIENT_REQUEST_SERVICE_SUBSCRIBE_MESSAGE=14;

    public static final int CLIENT_REPONSE_SERVICE_SUBSCRIBE_MESSAGE=15;

    public static final int CLIENT_REQUEST_SERVICE_CHANGE_MESSAGE=16;

    public static final int CUR_SERVER_NODE_SOLT_METADATA_REPLICAS_MESSAGE=17;

    public static final int SOLT_METADATA_REPLICAS_MESSAGE=18;

    public static final int SERVERNODE_REPLICAS_RELATIONSHIP_MESSAGE=19;

    public static final int SERVERNODE_REBALANCE_MESSAGE=20;


    private static final Map<Integer,Class> CLIENT_MESSAGE_TO_SERIALIZABLE=new HashMap<>();
    static {
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_SOLT_METADATA_MESSAGE, FetchSlotsAllocationRequstSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_RESPONSE_SOLT_METADATA_MESSAGE, FetchSlotsAllocationResponseSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_ALL_SERVER_LIST_MESSAGE, FetchAllServerListRequestSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_RESPONSE_ALL_SERVER_LIST_MESSAGE, FetchAllServerListReponseSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_SERVICE_REGISTER_MESSAGE, ServiceRegisterRequstSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REPONSE_SERVICE_REGISTER_MESSAGE, ServiceRegisterResponseSerializable.class);

        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_SERVICE_HEARBEAT_MESSAGE, ServiceHearbeatRequstSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REPONSE_SERVICE_HEARBEAT_MESSAGE, ServiceRegisterResponseSerializable.class);

        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_SERVICE_SUBSCRIBE_MESSAGE, ServiceSubscribeRequstSerializable.class);
        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REPONSE_SERVICE_SUBSCRIBE_MESSAGE, ServiceSubscribeResponseSerializable.class);

        MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.put(MessageType.CLIENT_REQUEST_SERVICE_CHANGE_MESSAGE, ServiceInstanceChangeSerializable.class);


    }

    public static Class getClientMessageSerializableClass(Integer messageType){
        return MessageType.CLIENT_MESSAGE_TO_SERIALIZABLE.get(messageType);
    }
}
